#ifndef PROTOCOLDEF_H
#define PROTOCOLDEF_H
#include "headerinclude.h"

#if defined(Q_OS_WIN32)
    const static QString sSysPath = "..\\..\\Protocol\\SysFolder";
    const static QString sSysFileName = "Systems.xml";
    const static QString sSubPath = sSysPath+"\\System";
    const static QString sQicoPath = ":Icon/ICON_4_1.ico";
#elif defined(Q_OS_MAC )
    const static QString sSysPath = "/Users/hus/Hus/code/Qt/system-protocol/Protocol/SysFolder";
    const static QString sSysFileName = "Systems.xml";
    const static QString sSubPath = sSysPath+"/System";
    const static QString sQicoPath = ":Icon/ICON_4_1.ico";
#endif

//数据类型定义
using CHAR              = char;
using UCHAR             = unsigned char;
using SHORT             = short;
using USHORT            = unsigned short;
using INT               = int;
using UINT              = unsigned int;
using BOOL              = bool;
using FLOAT             = float;
using DOUBLE            = double;
using INT64             = long long;
using UINT64            = unsigned long long;
using VOID              = void;


//面板的类型
enum PanelType
{

    SYSPANEL        = 0,
    SUBPANEL        = 1,
    SUBDATAPANEL    = 2,
    FINDPANEL       = 3,
};

//面板编辑的类型
enum EditType
{
    NOTTODO,
    ADD_DATA,
    EDIT_DATA
};

//协议类型
enum ProtocolType
{
    NOT = -1,
    SERVER = 0,     //服务端
    CLIENT = 1,     //客户端
};

//数据类型
enum PROTOCOLDATATYPE
{
    T_NOT             =-1,
    T_BOOL            =0,
    T_CHAR            =1,
    T_UCHAR           =2,
    T_SHORT           =3,
    T_USHORT          =4,
    T_INT             =5,
    T_UINT            =6,
    T_INT64           =7,
    T_UINT64          =8,
    T_FLOAT           =9,
    T_DOUBLE          =10,
    T_STRUCT          =11,
    T_UNION           =12,
    T_STRING          =13,
    T_ARRAY           =14,
};

//内存的数据是否被操作过标记
typedef enum DataState
{
    NotStatus       =0,
    MoDif           =1,
    Delete          =2,
}DATASTATUS;

//数据类型
typedef struct SubProDataInfo
{
    PROTOCOLDATATYPE    nType;      //数据类型
    QString                                 sInfo;      //数据描述
    QString                                 sRemarks;
    DATASTATUS m_Status;
    SubProDataInfo():m_Status(NotStatus),sInfo(""),sRemarks(""),nType(T_NOT){}
}SUBPRODATAINFO,*PSUBPRODATAINFO;


//子系统数据集合
typedef struct SubProDef
{
    USHORT          nSubId;         //子系统id
    ProtocolType    nType;          //子系统类型
    QString         sSubName;       //子系统名称
    QVector<SUBPRODATAINFO> m_SubProInfo;
    DATASTATUS m_Status;
    SubProDef():nSubId(-1),nType(NOT),sSubName(""),m_Status(NotStatus){}
}SUBPRODEF,*PSUBPRODEF;


//父数据集合
typedef struct SysProDef
{
    USHORT  nId;
    QString sName;
    QVector<SUBPRODEF> m_SubPro;
    DATASTATUS m_Status;
    SysProDef():nId(-1),sName(""),m_Status(NotStatus){}
}SYSPRODEF,*PSYSPRODEF;

//查找数据临时存放的地方（只匹配父协议/子协议）
typedef struct FindData
{
    INT nSysId;
    QString sMsg;
    struct SubData
    {
        INT nSubId;
        QString sSubData;
        ProtocolType eType;
        SubData():nSubId(-1),sSubData(""){}
    };
    QVector<SubData> m_SubVector;

    FindData():nSysId(-1),sMsg("")
    {
        m_SubVector.clear();
    }
}FINDDATA,*PFINDDATA;

#endif // PROTOCOLDEF_H
